import { Component } from 'react';
import Taro, { getCurrentInstance } from '@tarojs/taro';
import { View, Text, Image } from '@tarojs/components'
import { connect } from 'react-redux'
import { AtInputNumber } from 'taro-ui'
import CarInfo from '@/components/CarInfo'
import { getMaintainSchemeData, getFactoryManualData, getGoodsLaborFee } from '@/api/assistant'
import classnames from 'classnames'
import { staticUrl, accAdd, accMul } from '@/utils'
import './index.scss'
interface State {
  items: any,
  carInfo: any,
  realname: string,
  id: string | number,
  time: number,
  checkboxOption: object,
  checkedList: object,
  manualShow: boolean,
  currentCar: any,
  expiredItems: any,
  unexpiredItems: any,
  cart: object, //用户选择的可报价商品
  defaultCart: Object, //接口返回的默认可报价商品
  shopCartViewShow: Boolean,
  btnDisabled: Boolean,
  isContinue: Boolean, //是否继续执行（车辆数据更新执行列表接口）
}
const recommend_s_1 = staticUrl('/img/assistant/recommend_s_1.png')
const recommend_s_2 = staticUrl('/img/assistant/recommend_s_2.png')
const recommend_s_3 = staticUrl('/img/assistant/recommend_s_3.png')
const recommend_s_4 = staticUrl('/img/assistant/recommend_s_4.png')

@connect<any>(({ car }) => ({
  car: car.carInfo.currentCar
}))
export default class Index extends Component {
  $instance = getCurrentInstance();
  constructor (props) {
    super(props)
    this.state = {
      items: [],
      expiredItems: [],
      unexpiredItems: [],
      carInfo: {},
      currentCar: {}, // 默认车辆
      realname: '',
      id: '',
      time: 5,
      checkboxOption: [{
        value: 1,
        label: '',
        desc: ''
      }],
      checkedList: [1],
      manualShow: false,
      shopCartViewShow: false,
      cart: { //购物车数据
        cartList: [],
        totalPrice: 0,
        laborTotalPrice: 0,
        totalNum: 0
      },
      defaultCart: { //购物车数据
        cartList: [],
        totalPrice: 0,
        laborTotalPrice: 0,
        totalNum: 0,
        init: false,
      },
      btnDisabled: true,
      isContinue: true
    }
  }

  state: State


  UNSAFE_componentWillMount() { }
  componentDidMount() {
    // const { car } = this.props
    // console.log('car', car)
    // 抽奖转盘闪烁效果

  }
  parseQueryString(url) {
    let arr = url.split('=')[1]
    return arr
  }
  UNSAFE_componentWillReceiveProps(nextProps, nextContext) {
    let { isContinue } = this.state
    console.log('isContinue', isContinue)
    console.log('nextProps.car', nextProps.car)
    this.setState({
      currentCar: nextProps.car
    })
    if (!isContinue) return
    this.getMaintainSchemeData(nextProps.car)
    this.getFactoryManualData(nextProps.car)
  }
  componentDidShow() {
    this.setState({ isContinue: true })
    let MAINTAIN_SCHEME_GOODS = Taro.getStorageSync('MAINTAIN_SCHEME_GOODS')
    if (MAINTAIN_SCHEME_GOODS) {
      this.setState({ items: MAINTAIN_SCHEME_GOODS }, () => {
        Taro.removeStorageSync('MAINTAIN_SCHEME_GOODS')
        this.calculateAmount()
      })
    }
  }

  getFactoryManualData(currentCar) {
    let { id, carLicense, jekunModelCode } = currentCar
    console.log('currentCar', currentCar)
    getFactoryManualData({
      userCarId: id,
      carLicense,
      jekunModelCode
    }).then(res => {
      let data = res.data.data
      let { expiredItems, unexpiredItems } = data
      this.setState({
        expiredItems,
        unexpiredItems
      })
    })
  }
  getMaintainSchemeData(currentCar) {
    let { id, carLicense, jekunModelCode } = currentCar
    console.log('currentCar', currentCar)
    Taro.removeStorageSync('MAINTAIN_SCHEME_GOODS')
    Taro.removeStorageSync('MAINTAIN_SCHEME_CAR')
    this.setState({
      items: []
    })
    Taro.showLoading({ title: '加载中..' })
    getMaintainSchemeData({
      userCarId: id,
      carLicense,
      jekunModelCode
    }).then(res => {
      Taro.hideLoading()
      let data = res.data.data
      let { carInfo, items } = data
      items.forEach(e => {
        e.projectItems.forEach(v => {
          if (v.goodsMatchData) {
            v.goodsMatchData.goodsItems = v.goodsMatchData.goodsItems.map(i => {
              return {
                ...i,
                defaultNumber: i.number
              }
            })
          }
        })
      })
      Taro.setStorageSync('MAINTAIN_SCHEME_CAR', carInfo)
      items.forEach(e => {
        let findIndex = e.projectItems.findIndex(v => v.isDefaultSelected && v.exclusionVal && v.relatedVal)
        e.projectItems = e.projectItems.map(v => {
          return {
            ...v,
            isDisabled: false,
            disabledMsg: ''
          }
        })
        if (findIndex >= 0) {
          let row = e.projectItems[findIndex]
          console.log('rowrow', row)
          e = this.formatItems(e, row.baseServiceId, row.relatedVal, row.exclusionVal, row.isDefaultSelected)
        }
      })
      this.setState({
        carInfo,
        items
      }, () => {
        this.calculateAmount()
      })
    })
  }


  //下单
  handleSubmit() {
    let STORECODE = Taro.getStorageSync('STORECODE')
    let { cart, btnDisabled, items } = this.state
    if (btnDisabled) return
    Taro.setStorageSync("CARTGOODS", cart)
    Taro.setStorageSync("MAINTAIN_SCHEME_GOODS", items)
    this.setState({ isContinue: false })
    Taro.navigateTo({
      url: `/pages/order/index/index?isCarMaintain=1&storeCode=${STORECODE}`,
    })
  }
  handleExchange = (idx, pIdx, gIdx) => {
    let { currentCar, items } = this.state
    let projectItems = items[idx].projectItems[pIdx]
    Taro.setStorageSync("MAINTAIN_SCHEME_GOODS", items)
    Taro.navigateTo({
      url: `/pages/assistant/exchange/index?jekunModelCode=${currentCar.jekunModelCode}&carLicense=${currentCar.carLicense}&projectId=${projectItems.projectId}&goodsId=${projectItems.goodsMatchData.goodsItems[gIdx].goodsId}&categoryId=${items[idx].categoryId}`
    })
  }

  //修改数量
  handleChange = (e, idx, idx1, idx2) => {
    let { shopCartViewShow } = this.state
    if (shopCartViewShow && e < 1) {
      Taro.showModal({
        title: '提示',
        content: "确定删除该商品？",
        success: (res) => {
          if (res.confirm) {
            this.changeNumber(e, idx, idx1, idx2)
          }
        },
        fail: () => {
        }
      })
      return
    }
    this.changeNumber(e, idx, idx1, idx2)

  }
  changeNumber(e, idx, idx1, idx2) {
    let { items } = this.state
    items[idx].projectItems[idx1].goodsMatchData.goodsItems[idx2].number = e
    let projectItem = items[idx].projectItems[idx1]
    this.getGoodsLaborFee(projectItem.projectId, JSON.stringify(items[idx].projectItems[idx1].goodsMatchData.goodsItems.map(i => {
      return {
        goodsId: i.goodsId,
        num: i.number
      }
    })), idx, idx1)
    let totalPrice = 0
    let isDefaultSelected = items[idx].projectItems[idx1].isDefaultSelected
    items[idx].projectItems[idx1].goodsMatchData.goodsItems.forEach(e => {
      totalPrice = accAdd(Number(totalPrice), accMul(e.salePrice, e.number))
    })
    if (items[idx].projectItems[idx1].goodsMatchData.goodsItems.filter(e => e.number).length == 0) {
      isDefaultSelected = 0
    }
    items[idx].projectItems[idx1].goodsMatchData.totalPrice = totalPrice
    items[idx].projectItems[idx1].isDefaultSelected = isDefaultSelected
    this.setState({
      items
    })
  }
  //获取工时费
  getGoodsLaborFee(projectId, goodsItems, idx, idx1) {
    let { items } = this.state
    getGoodsLaborFee({
      projectId,
      goodsItems
    }).then(res => {
      let data = res.data
      items[idx].projectItems[idx1].goodsMatchData.laborFee = data.laborTotalPrice
      this.setState({
        items
      }, () => {
        this.calculateAmount()
      })
    })
  }

  handleClose(key) {
    this.setState({
      [key]: false,
    })
  }

  handleOpen(key) {
    this.setState({
      [key]: true
    })
  }

  handleQuotation() {
    let { defaultCart } = this.state
    Taro.setStorageSync("CARTGOODS", defaultCart)
    this.setState({ isContinue: false })
    Taro.navigateTo({
      url: '/pages/order/index/index?isCarMaintain=1',
    })
  }

  // 原厂手册
  manualInfo() {
    let { expiredItems, unexpiredItems, carInfo } = this.state
    return (
      <View className='self-dialog'>
        <View className='self-mask' onClick={() => this.handleClose('manualShow')}></View>
        <View className='self-content'>
          <View className='self-title'>
            <Text className='cancel' onClick={() => this.handleClose('manualShow')}>取消</Text>
            <View className='title-txt'><View className='carModel'>{carInfo.carModelShortLabel}</View>·原厂手册</View>
          </View>
          <View className='manual-box'>
            <View className='manual-item'>根据您当前里程、上次保养记录来计算原厂手册中项目是否到期。若存在到期计算不准确，请及时更新相关信息。</View>
            <View className='manual-title title-1'>
              <Text className='title-icon-1'></Text>
              已到期（{expiredItems.length}项）
            </View>

            {
              expiredItems && expiredItems.length > 0 ? expiredItems.map((item, idx) => {
                return <View className='manual-item suggest' key={idx}>
                  <View className='r-top'>
                    <View className='r-name'>{item.projectName}</View>
                    {
                      item.expireInfo && item.expireInfo.msg ? <View className='tips-box'>
                        <Text className='icon-1'></Text>
                        <Text className='tips-txt'>{item.expireInfo.msg}</Text>
                      </View> : null
                    }

                  </View>
                  {
                    item.projectDesc ? <View className='suggest-txt-1'>{item.projectDesc}</View> : null
                  }

                  {
                    item.manualData ? <View className='suggest-txt-2'>
                      <Text className='suggest-tag'>原厂建议</Text>{item.manualData.suggest}
                    </View> : null
                  }

                </View>
              }) : null
            }




            <View className='manual-title title-2'>
              <Text className='title-icon-2'></Text>
              未到期（{unexpiredItems.length}项）
            </View>

            {
              unexpiredItems && unexpiredItems.length > 0 ? unexpiredItems.map((item, idx) => {
                return <View className='manual-item suggest' key={idx}>
                  <View className='r-top'>
                    <View className='r-name'>{item.projectName}</View>
                    {
                      item.expireInfo && item.expireInfo.msg ? <View className='tips-box'>
                        <Text className='icon-1'></Text>
                        <Text className='tips-txt'>{item.expireInfo.msg}</Text>
                      </View> : null
                    }

                  </View>
                  {
                    item.projectDesc ? <View className='suggest-txt-1'>{item.projectDesc}</View> : null
                  }

                  {
                    item.manualData ? <View className='suggest-txt-2'>
                      <Text className='suggest-tag'>原厂建议</Text>{item.manualData.suggest}
                    </View> : null
                  }

                </View>
              }) : null
            }

          </View>
          <View className='h120'></View>
          {
            expiredItems.length > 0 ? <View className='manual-btn'>
              <View className='btn' onClick={() => { this.handleQuotation() }}>按到期项目报价</View>
            </View> : null
          }

        </View>
      </View>
    )
  }
  //购物车
  shopCartView() {
    let { items, cart } = this.state
    return <View className='shop-cart-dialog'>
      <View className='shop-cart-body'>
        <View className='dialog-header'>
          <View className='cancel-btn' onClick={() => this.handleClose('shopCartViewShow')}>取消</View>
          养车方案
        </View>
        <View className='cart-list'>
          {
            items && items.length ? items.map((item, idx) => {
              let projectItems = item.projectItems || []
              if (projectItems.length && projectItems.filter(v => v.isDefaultSelected && v.goodsMatchData).length) {
                return <View className='cart-item' key={idx}>
                  <View className='cart-item-title'>{item.categoryName}
                    <View className='price'>￥<Text className='amount'>{item.totalPrice}</Text>起</View>
                  </View>
                  <View className='project-list'>
                    {
                      item.projectItems.map((project, pIdx) => {
                        if (project.isDefaultSelected && project.goodsMatchData && project.goodsMatchData.goodsItems.length) {
                          return <View className='project-item'>
                            <View className='project-item-name'>{project.projectName}
                              {
                                project.expireInfo && project.expireInfo.msg ? <View className='tips-box' >
                                  <Text className='icon-1'></Text>
                                  <Text className='tips-txt'>{project.expireInfo.msg}</Text>
                                </View> : null
                              }
                            </View>
                            <View className='goods-list'>
                              {
                                project.goodsMatchData && project.goodsMatchData.goodsItems.map((goods, gIdx) => {
                                  return <View className='goods-item'>
                                    <Image className='thumbnail' src={goods.goodsThumbnail}></Image>
                                    <View className='goods-info'>
                                      <View className='goods-name'>{goods.goodsName}</View>
                                      <View className='bottom'>
                                        <View className='price'>
                                          ￥{goods.salePrice}{Number(goods.salePrice) < Number(goods.maxSalePrice) && '起'}
                                        </View>
                                        {
                                          goods.editStatus && goods.editStatus === 1 ? <AtInputNumber
                                            type='number'
                                            min={0}
                                            step={1}
                                            max={goods.stockCount}
                                            value={goods.number}
                                            onChange={(e) => this.handleChange(e, idx, pIdx, gIdx)}
                                          /> : <View className='num' onClick={() => { this.handleSummary(idx, pIdx, gIdx) }}>x{goods.number}</View>
                                        }

                                      </View>
                                    </View>
                                  </View>
                                })
                              }
                            </View>
                          </View>
                        }
                      })
                    }
                  </View>
                </View>
              }
            }) : null
          }
        </View>
      </View>
    </View>
  }

  handleProjectClick = (idx1, idx2) => {
    let { items } = this.state
    let row = items[idx1].projectItems[idx2]
    if (row.isDisabled) {
      Taro.showModal({
        title: '提示',
        content: row.disabledMsg,
        showCancel: false,
        confirmText: "知道了"
      })
      return
    }
    if (!row.isDefaultSelected && row.goodsMatchData.goodsItems.filter(e => e.number).length == 0) {
      row.goodsMatchData.goodsItems = row.goodsMatchData.goodsItems.map(e => {
        return {
          ...e,
          number: e.defaultNumber
        }
      })
    }
    items[idx1].projectItems.forEach(e => {
      e.isDisabled = false
      e.disabledMsg = ''
    })
    let isDefaultSelected = !row.isDefaultSelected
    let relatedVal = row.relatedVal //当前选中的关联值
    let baseServiceId = row.baseServiceId //当前选中的服务项目id
    let exclusionVal = row.exclusionVal //当前选中的互斥值
    if (relatedVal || exclusionVal) {
      let text = items[idx1].projectItems.filter(i => i.baseServiceId != baseServiceId && i.goodsMatchData && i.relatedVal == relatedVal).map(i => { return i.projectName }).join(',')
      if (text && !isDefaultSelected) {
        Taro.showModal({
          title: '提示',
          content: `如您坚持取消“ ${row.projectName} “,则“ ${text} “将一起取消`,
          confirmText: '考虑一下',
          confirmColor: "#ff0000",
          cancelText: '确认取消',
          success: (res) => {
            if (res.cancel) {
              items[idx1] = this.formatItems(items[idx1], baseServiceId, relatedVal, exclusionVal, isDefaultSelected)
              items[idx1].projectItems[idx2].isDefaultSelected = isDefaultSelected
              this.setState({
                items
              }, () => {
                this.calculateAmount()
                this.calculateProjectAmount(idx1, idx2)
              })
            }
          }
        })
      } else {
        items[idx1] = this.formatItems(items[idx1], baseServiceId, relatedVal, exclusionVal, isDefaultSelected)
        items[idx1].projectItems[idx2].isDefaultSelected = isDefaultSelected
        this.setState({
          items
        }, () => {
          this.calculateAmount()
          this.calculateProjectAmount(idx1, idx2)
        })
      }
    } else {
      items[idx1].projectItems[idx2].isDefaultSelected = isDefaultSelected
      this.setState({
        items
      }, () => {
        this.calculateAmount()
        this.calculateProjectAmount(idx1, idx2)
      })
    }

  }
  //格式化数据
  formatItems(items, baseServiceId, relatedVal, exclusionVal, isDefaultSelected) {
    let selectProjectName = items.projectItems.filter(i => i.baseServiceId == baseServiceId).map(i => { return i.projectName }).join(',')
    items.projectItems.filter(i => i.baseServiceId != baseServiceId).forEach(e => {
      if (e.relatedVal == relatedVal) { //该项目与选中项目关联
        e.isDefaultSelected = isDefaultSelected
        if (e.isDefaultSelected && e.exclusionVal) {
          items.projectItems.filter(i => i.baseServiceId != e.baseServiceId && i.baseServiceId != baseServiceId).forEach(v => {
            if (v.exclusionVal && e.exclusionVal == v.exclusionVal) {
              v.disabledMsg = `“ ${v.projectName} “、“ ${e.projectName} “选中一个保养即可，无需同时保养`
              v.isDisabled = true
            }
          })
        }
      }
      console.log('isDefaultSelected && exclusionVal && e.exclusionVal && exclusionVal == e.exclusionVal', isDefaultSelected, exclusionVal, e.exclusionVal, exclusionVal == e.exclusionVal)
      if (isDefaultSelected && exclusionVal && e.exclusionVal && exclusionVal == e.exclusionVal) { //该项目与选中的项目互斥
        e.disabledMsg = `“ ${selectProjectName} “、“ ${e.projectName} “选中一个保养即可，无需同时保养`
        e.isDisabled = true
      }
      if (e.isDisabled && e.relatedVal) { //该项目与选中项目互斥并且存在关联项目的
        items.projectItems.filter(i => i.baseServiceId != e.baseServiceId && i.baseServiceId != baseServiceId).forEach(v => {
          if (v.relatedVal && e.relatedVal == v.relatedVal) {
            v.disabledMsg = `“ ${selectProjectName} “、“ ${v.projectName} “选中一个保养即可，无需同时保养`
            v.isDisabled = true
          }
        })
      }
    })
    return items
  }
  //计算单个保养商品总金额
  calculateProjectAmount(idx1, idx2) {
    let { items } = this.state
    let totalPrice = 0
    items[idx1].projectItems[idx2].goodsMatchData.goodsItems.forEach(e => {
      totalPrice = accAdd(Number(totalPrice), accMul(e.salePrice, e.number))
    })
    items[idx1].projectItems[idx2].goodsMatchData.totalPrice = totalPrice
    this.setState({
      items
    }, () => { })
  }
  handleSummary = (idx, idx1, idx2) => {
    let { items } = this.state
    items[idx].projectItems[idx1].goodsMatchData.goodsItems[idx2].editStatus = 1
    this.setState({
      items
    })
  }
  //计算金额
  calculateAmount() {
    let { items, defaultCart, currentCar, carInfo } = this.state
    let cartList = []
    let totalPrice = 0
    let laborTotalPrice = 0
    let totalNum = 0
    let btnDisabled = true //没选中禁用下单按钮
    items.forEach(e => {
      e.totalPrice = 0
      e.projectItems.forEach(v => {
        if (v.isDefaultSelected && v.goodsMatchData) {
          btnDisabled = false
          totalNum++
          let goodsTotalPrice = 0
          cartList = cartList.concat(v.goodsMatchData.goodsItems.map(i => {
            e.totalPrice = accAdd(Number(e.totalPrice), accMul(i.salePrice, i.number))
            goodsTotalPrice = accAdd(Number(goodsTotalPrice), accMul(i.salePrice, i.number))
            return {
              ...i,
              itemName: i.goodsName,
              itemNumber: i.number,
              itemPrice: i.salePrice || '0',
              itemLogo: i.goodsThumbnail,
              goods: {
                id: i.goodsId,
                laborFee: i.labor && i.labor.laborPrice || 0
              },
              goodsSku: { id: i.defaultGoodsSkuId }
            }
          }))
          laborTotalPrice = accAdd(Number(laborTotalPrice), Number(v.goodsMatchData.laborTotalPrice))
          v.goodsMatchData.totalPrice = goodsTotalPrice
        }
      })
      totalPrice = accAdd(Number(totalPrice), Number(e.totalPrice))
    })
    if (!defaultCart.init) {
      defaultCart = { cartList, totalPrice, laborTotalPrice, totalNum, init: true, carInfo: carInfo }
    }
    this.setState({
      cart: { cartList, totalPrice, laborTotalPrice, totalNum, carInfo: carInfo },
      btnDisabled,
      items,
      defaultCart
    }, () => {
      console.log(this.state.cart)
    })
  }


  render() {
    let { expiredItems, manualShow, carInfo, items, cart, shopCartViewShow, btnDisabled } = this.state;

    return (
      <View className="assistant" >
        <CarInfo styleView='4' extra={carInfo} />
        <View className='assistant-title'>
          <View className='t-top'>
            <View className='t-top__l'><Text className='txt'>{carInfo.carModelShortLabel}</Text>养车方案</View>
            <View className='t-top__r' onClick={() => this.handleOpen('manualShow')}><Text className='ico'></Text>原厂手册</View>
          </View>
          {
            expiredItems.length != 0 ? <View className='t-b'>
              <View className='t-b__l'></View>
              <View className='t-b__r'>{expiredItems.length}项到期</View>
            </View> : null
          }

        </View>

        <View className='assistant-list'>
          {
            items && items.length ? items.map((item, idx) => {
              return <View className='assistant-item' key={idx}>
                <View className='title'>{item.categoryName}</View>
                {
                  item.projectItems && item.projectItems.length ? item.projectItems.map((project, pIdx) => {
                    return <View className={classnames('item-box', {
                      'active': project.isDefaultSelected == 1,
                    })}>
                      <View className='item-box__l' onClick={() => project.goodsMatchData && this.handleProjectClick(idx, pIdx)}>
                        {
                          project.goodsMatchData && <View className='self-checkbox'></View>
                        }
                        {
                          project.goodsMatchData && <View className='checkbox-active'></View>
                        }
                        {
                          !project.goodsMatchData && <View className='checkbox-disabled'></View>
                        }
                        {
                          !project.goodsMatchData && <View className='self-checkbox-disabled'></View>
                        }

                      </View>

                      <View className='item-box__r'>
                        <View className='r-top'>
                          <View className='r-top-inner'>
                            <View className='r-name'>{project.projectName}</View>
                            {
                              project.goodsMatchData ? <View className='r-price'>
                                <Text className='u'>￥</Text><Text className='n'>{project.goodsMatchData.totalPrice}</Text><Text className='t'>起</Text>
                              </View> : null
                            }

                          </View>
                          {
                            project.expireInfo && project.expireInfo.msg ? <View className='tips-box' >
                              <Text className='icon-1'></Text>
                              <Text className='tips-txt'>{project.expireInfo.msg}</Text>
                            </View> : null
                          }

                        </View>

                        <View className='suggest'>
                          <View className='suggest-txt-1'>{project.projectDesc}</View>
                          {
                            project.suggestInfo && project.suggestInfo.msg ? <View className='suggest-txt-2'>
                              <Text className='suggest-tag'>原厂建议</Text>{project.suggestInfo.msg}
                            </View> : null
                          }

                        </View>
                        <View className='item-block__wrap'>
                          <View>
                            {
                              project.goodsMatchData ? project.goodsMatchData.goodsItems.map((goods, gIdx) => {
                                return <View className='item-block'>
                                  <View className='info-box'>
                                    <View className='ib__l'>
                                      <Image className='pro-pic' src={goods.goodsThumbnail}></Image>
                                      {
                                        goods.recommendType === 1 ? <Image className='recommand-tag' src={recommend_s_1}></Image> :
                                          goods.recommendType === 2 ? <Image className='recommand-tag' src={recommend_s_2}></Image> :
                                            goods.recommendType === 3 ? <Image className='recommand-tag' src={recommend_s_3}></Image> :
                                              goods.recommendType === 4 ? <Image className='recommand-tag' src={recommend_s_4}></Image> : null
                                      }
                                    </View>
                                    <View className='ib__r'>
                                      <View className='ib__in'>
                                        <View className='ib-text'>{goods.goodsName}</View>
                                        <View className='ib-ex' onClick={() => this.handleExchange(idx, pIdx, gIdx)}>更换</View>
                                      </View>
                                      <View className='ib__dts'>
                                        <View className='dts__l'>￥{goods.salePrice}{Number(goods.salePrice) < Number(goods.maxSalePrice) && '起'}</View>
                                        {
                                          goods.editStatus && goods.editStatus === 1 ? <AtInputNumber
                                            type='number'
                                            min={0}
                                            step={1}
                                            max={goods.stockCount}
                                            value={goods.number}
                                            onChange={(e) => this.handleChange(e, idx, pIdx, gIdx)}
                                          /> : <View className='dts__r' onClick={() => { this.handleSummary(idx, pIdx, gIdx) }}>x{goods.number}</View>
                                        }

                                      </View>
                                    </View>
                                  </View>
                                </View>
                              }) : <View className='no-product'>{project.msg}</View>
                            }

                          </View>
                          {
                            project.goodsMatchData ? <View className='time'><Text className='time-txt'>工时费</Text> <Text className='time-ico'></Text>	<Text className='time-price'>￥{project.goodsMatchData.laborTotalPrice}</Text></View> : null
                          }

                        </View>

                      </View>
                    </View>
                  }) : null
                }

              </View>
            }) : null
          }


        </View>

        <View className='assistant-opration'>
          <View className='opration__l'>
            <View className='cart-num' onClick={() => !shopCartViewShow && !btnDisabled ? this.handleOpen('shopCartViewShow') : this.handleClose('shopCartViewShow')}>
              <Text className='num'>{cart.totalNum}</Text>
            </View>
            <View className='l-sum'>
              <View className='sum-box'>￥
                <Text className='sum'>{cart.totalPrice}</Text>起
              </View>
              <View className='contain'>含工时费 ￥{cart.laborTotalPrice}</View>
            </View>
          </View>
          <View className={classnames('submit-btn', { 'disabled': btnDisabled })} onClick={() => this.handleSubmit()}>
            去下单
          </View>
        </View>

        {
          manualShow && this.manualInfo()
        }
        {
          shopCartViewShow && this.shopCartView()
        }


      </View >
    )
  }
}
